<?xml version="1.0"?>
<OnTheFlyInstruction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <InstanceId>CSOM - Update Field</InstanceId>
  <CustomAppConfig />
  <Tags>
    <string>SharePoint Client</string>
	<string>CSOM</string>
  </Tags>
	<Description>
	Update MultiTextField using CSOM
	Shows how to cast and update a field both in web and list scope</Description>
  <AdditionalAssemblies />
  <Code><![CDATA[// ----------------------
//  Update MultiTextField using CSOM
//  Shows how to cast and update a field both in web & list scope
// ----------------------
  
using System;
using System.Linq;
using System.Net;
using Microsoft.SharePoint.Client;
using xSolon.Instructions;
using xSolon.SP.ManagedClient;

public class SP14Client_Sample : AbstractInstruction
{
	public override void Run()
	{
		SP14ClientHelper instr = new SP14ClientHelper();
		
		NetworkCredential creds = null;
		
		creds = this.CredentialCache.First();
		
		var ctx = instr.GetContext("http://localhost",SP14AuthenticationType.Windows, creds);
	
		var siteField = ctx.Web.Fields.GetByInternalNameOrTitle("Transcript");
		
		var mSiteField = ctx.CastTo<FieldMultiLineText>(siteField);
		
		ctx.Load(mSiteField);
		ctx.ExecuteQuery();
		
		NotifyInformation("Before: {0}", mSiteField.RichText.ToString());
		mSiteField.RichText = true;
		
		mSiteField.UpdateAndPushChanges(true);
		
		ctx.Load(mSiteField);
		
		NotifyInformation("After: {0}", mSiteField.RichText.ToString());
		
		ctx.ExecuteQuery();
		
		var list = ctx.Web.Lists.GetByTitle("Healthy Moments");
		
		var field = list.Fields.GetByInternalNameOrTitle("Transcript");
	
		var mField = ctx.CastTo<FieldMultiLineText>(field);
		
		ctx.Load(mField);
		
		ctx.ExecuteQuery();
		
		NotifyInformation(mField.RichText.ToString());
		
		Response = field.SchemaXml;
		
	}

}]]></Code>
</OnTheFlyInstruction>